﻿using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace OpenLS.Spreadsheet.StandardAddIn
{
    internal static class Enumerable
    {
        public static IEnumerable<TResult> Select<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, TResult> selector)
        {
            Contract.Assert(source != null);
            Contract.Assert(selector != null);
            return selectIterator(source, selector);
        }
        private static IEnumerable<TResult> selectIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, TResult> selector)
        {
            foreach (var sourceItem in source)
            {
                yield return selector(sourceItem);
            }
        }


    }
}